<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="clock">
        <p class="date">
            <span id="date">2022:12:01</span>
            <span id="week">星期三</span>
        </p>
        <p class="time">
            <span id="time">
                 18:00:00
            </span>
        </p>
    </div>
</body>
<style>
    html,
    body {
        height: 100%;
    }
    
    body {
        background: #0f3854;
        /*background: radial-gradient(ellipse at center, #0a2e38 0%, #000, 0%);*/
        /*background-size: 100%;*/
    }
    
    p {
        margin: 0;
        padding: 0;
    }
    
    .clock {
        text-align: center;
        padding-top: 150px;
        color: #daf6ff;
        text-shadow: 0 0 20px #0aafe6;
    }
    
    .time {
        font-size: 50px;
        padding: 5px 0;
        letter-spacing: 5px;
    }
    
    .date {
        letter-spacing: 2px;
        font-size: 16px;
    }
</style>
<script>
    let weekArr = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六', ]

    function addZero(num) {
        if (num >= 10) {
            return num
        } else {
            return "0" + num
        }
    }

    let dateDom = document.getElementById("date")
    let weekDom = document.getElementById("week")
    let timeDom = document.getElementById("time")

    function updateTime() {
        let now = new Date();
        let date = now.getFullYear() + "-" + addZero(now.getMonth() + 1) +
            "-" + addZero(now.getDate());
        let week = weekArr[now.getDay()];
        let time = addZero(now.getHours()) + ":" + addZero(now.getMinutes()) + ":" + addZero(now.getSeconds())
        setText(dateDom, date)
        setText(weekDom, week)
        setText(timeDom, time)
    }

    function setText(dom, text) {
        dom.innerText = text;
    }
    setInterval(updateTime, 1000)
    updateTime()
</script>

</html>